package com.exam.user.service;

import com.exam.user.api.entity.SysUser;
import com.exam.user.dao.SysUserDao;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class SysUserServiceImpl implements SysUserService {
    @Resource
    private SysUserDao sysUserDao;

    @Override
    public void addUser(SysUser user) {
            sysUserDao.addUser(user);
    }

    @Override
    public void updateUser(SysUser user) {
            sysUserDao.updateUser(user);
    }

    @Override
    public void deleteUserById(Integer id) {
            sysUserDao.deleteUserById(id);
    }

    @Override
    public SysUser getSingle(Integer id) {

        return sysUserDao.getSingle(id);
    }

    @Override
    public PageInfo<SysUser> getAll(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        PageInfo<SysUser> users=new PageInfo<>(sysUserDao.getAll());
        return users;
    }

    @Override
    public List<SysUser> getByLike(String username) {

        return sysUserDao.getByLike(username);
    }
}
